package com.egg.ylt.presenter.impl;

import com.egg.ylt.Utils.API;
import com.egg.ylt.pojo.HomePageEntity;
import com.egg.ylt.presenter.ICollectNewsPresenter;
import com.egg.ylt.view.ICollectNewsView;
import com.yonyou.framework.library.bean.ErrorBean;
import com.yonyou.framework.library.common.CommonUtils;
import com.yonyou.framework.library.mvp.impl.BasePresenter;
import com.yonyou.framework.library.net.ReqCallBack;
import com.yonyou.framework.library.net.RequestManager;

import java.util.HashMap;

/**
 * sichaoqi on 2018/12/14
 */
public class CollectNewsPresenterImpl extends BasePresenter<ICollectNewsView> implements ICollectNewsPresenter {
    @Override
    public void getNewsData(String token, String companyId, String type, String pageSize, String pageNum ) {
        mView.showDialogLoading("数据加载中");
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("token", token);
        hashMap.put("companyId", companyId);
        hashMap.put("type", type );
        hashMap.put("pageSize", pageSize );
        hashMap.put("pageNum", pageNum );
        RequestManager.getInstance().requestPostByAsyn(API.POST_COLLECT_SHOP, hashMap, new ReqCallBack<HomePageEntity>() {

            @Override
            public void onReqSuccess(HomePageEntity result) {
                mView.dismissDialogLoading();
                mView.getNewsData(result);
            }

            @Override
            public void onFailure(String result) {
                mView.dismissDialogLoading();
                CommonUtils.makeEventToast(mContext, result, false);
            }

            @Override
            public void onReqFailed(ErrorBean error) {
                mView.dismissDialogLoading();
                CommonUtils.makeEventToast(mContext, error.getMsg(), false);
            }
        });
    }
}
